<?php
require '../$header.php';

$SpotID = $DB->escape($_POST['SpotID']);

$return = array();

$DB->query("
	SELECT m.*, u.FirstName, u.LastName, u.Email
	FROM message AS m
	INNER JOIN user AS u
	ON u.ID = m.UserID
	WHERE m.SpotID = '{$SpotID}'
	ORDER BY m.Time DESC
");

if($DB->num() > 0)
{
	while($fetch = $DB->fetch())
	{
		$return[] = $fetch;
	}
}

echo json_encode($return);

require '../$footer.php';
?>